package com.zmj.dao.impl;

import java.util.List;

import com.zmj.dao.IAddressDao;
import com.zmj.entity.Address;
import com.zmj.entity.Region;

public class AddressDaoImpl extends BaseDaoImpl implements IAddressDao{

	@Override
	public List<Region> selRegion(String superCode) {
		String sql="SELECT cri_code criCode,cri_name criName FROM cn_region_info WHERE cri_superior_code = ?";
		return sel(Region.class, sql, superCode);
	}

	@Override
	public boolean addAddress(Address address) {
		String sql="INSERT INTO address VALUES (default,?,?,?,?,?,?,?,?,?,default,default)";
		return add(sql, address.getUserId(),address.getProvince(),address.getCity(),address.getDistrict(),address.getAname(),address.getAemail(),address.getAmobile(),address.getAremark(),address.getIsDefault());
	}
	
	@Override
	public List<Address> selAddressesByUserId(int userId) {
		String sql="select * from address where userId = ?";
		return sel(Address.class, sql, userId);
	}
}
